package cn.u313.entry;

import lombok.Builder;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 * 用户表
 */
@Getter
@Setter
@Entity
@Table(name = "user")
public class UserEntry {
    @Id
    private int id;
    private String qq;
    private int m;
    private String qun;
    private int qiandao;
    private String sign;
    private String vxid;
    private String name;
    @Column(name = "hongBao")
    private double hongBao;//红包
    @Column(name = "open_id")
    private String openId;//QQ的开发id
    @Column(name = "qq_sign")
    private String qqSign;//openid 辅助绑定的验证

    @Column(name = "gpt_token")
    private Integer gptToken;


    @Override
    public String toString() {
        return "UserEntry{" +
                "id=" + id +
                ", qq='" + qq + '\'' +
                ", m=" + m +
                ", qun='" + qun + '\'' +
                ", qiandao=" + qiandao +
                ", sign='" + sign + '\'' +
                ", vxid='" + vxid + '\'' +
                ", name='" + name + '\'' +
                ", hongBao=" + hongBao +
                ", openId='" + openId + '\'' +
                ", qqSign='" + qqSign + '\'' +
                '}';
    }

    /**
     * 加减悦币
     * @param q
     * @return
     */
    public boolean payMe(int q) {
        if(m+q>=0){
            setM(m+q);
            return true;
        }
        return false;
    }
    public boolean payToken(int q) {
        if(gptToken+q>=0){
            setGptToken(gptToken+q);
            return true;
        }
        return false;
    }
    /**
     * 加减悦币
     * @param hb
     * @return
     */
    public boolean payMe(double hb) {
        if(hongBao+hb>=0){
            setHongBao(hongBao+hb);
            return true;
        }
        return false;
    }
}
